﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Client
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "MP3音频文件|*.mp3";
            if (DialogResult.OK.Equals(dlg.ShowDialog()))
            {
                this.label1.Text = dlg.FileName;
                this.label2.Text = "准备就绪。";
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (!File.Exists(this.label1.Text))
            {
                return;
            }
            FileStream fs = new FileStream(this.label1.Text, FileMode.Open, FileAccess.Read);
            ServiceReference1.ServiceClient cl = new ServiceReference1.ServiceClient();
            this.button2.Enabled = false;
            bool isSucc = true;
            var response = cl.UpLoadFile(Path.GetFileName(this.label1.Text), fs, out isSucc);
            this.button2.Enabled = true;
            if (isSucc)
                this.label2.Text = "上传完成。";
            else
                this.label2.Text = "错误信息：" + response;

        }
    }
}
